<?php
session_start();
include_once 'db.php';

$userName = $_POST["userName"];
$password = $_POST["password"];

$queryStr = "select *, (select g_desc from d_gender where g_code = gender) as gender_desc from l_user where user_name = %q and password = %q";
$param = array($userName, $password);
$result = dbOperate($queryStr, $param);

$row = mysql_fetch_assoc($result);

if($row) {
    $_SESSION["user"] = serialize($row[0]);
    $_SESSION["passed"] = true;
    $_SESSION['msg'] = '登录成功';

    echo json_encode($row);
} else {
    $_SESSION["passed"] = false;
    $_SESSION['msg'] = '登录失败,请检查用户名或密码';
    echo (null);
}

?>